package com.bootdo.api.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * io流工具类
 * @author hrh
 * @date 2016年5月27日 下午3:29:37
 */
public class IOUtils {
	
	/**
	 * 将流信息转String
	 * @param inputStream
	 * @return
	 */
	public static String inputStreamToStr(InputStream inputStream) {
		StringBuffer buf = new StringBuffer();
		BufferedReader br = null;
		try {
			br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
			String line;
			while (null != (line = br.readLine())) {
				buf.append(line).append("\n");
			}
			buf.toString();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
				inputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return buf.toString();
	}
}
